Skip to content

[Improvement]: Load process factories via DefaultTableRuntimeFactory#4100

Open
baiyangtx wants to merge 3 commits intoapache:masterfrom
baiyangtx:upstream/table-runtime-factory
Open

[Improvement]: Load process factories via DefaultTableRuntimeFactory#4100
baiyangtx wants to merge 3 commits intoapache:masterfrom
baiyangtx:upstream/table-runtime-factory

Conversation

@baiyangtx
Copy link
Contributor

@baiyangtx baiyangtx commented Feb 26, 2026

Summary

This PR is a subtask of #4100

Wire the new process plugin model(Introduced by #4097) into AMS so that table processes are discovered from ProcessFactory implementations and scheduled via the existing ProcessService.

Details

  • Promote ProcessFactory to the single extension point for table processes.

    • DefaultTableRuntimeFactory aggregates all ProcessFactory implementations, exposes derived ActionCoordinators, and merges their requiredStates() with DefaultTableRuntime.REQUIRED_STATES.
  • Simplify TableRuntimeFactory so it only describes table runtime & process wiring.

    • It no longer extends ActivePlugin; lifecycle methods (open/close/name) are removed from the interface and from DefaultTableRuntimeFactory.
  • Wire AMS directly to DefaultTableRuntimeFactory instead of a generic plugin manager.

    • AmoroServiceContainer creates a single DefaultTableRuntimeFactory, passes it to DefaultTableService, then initializes it with all ProcessFactory implementations and uses supportedCoordinators() to build the coordinator list for ProcessService.
    • DefaultTableService now depends on a TableRuntimeFactory directly and uses it to create TableRuntime instances.
  • Clean up ProcessService constructors to match the new model.

    • Remove the deprecated constructor using ActionCoordinatorManager.
    • AMS uses the constructor with an explicit List<ActionCoordinator>; tests use the 2‑argument convenience overload.

## Summary

Wire the new process plugin model into AMS so that table processes are discovered from `ProcessFactory` implementations and scheduled via the existing `ProcessService`.

## Details

- Extend `DefaultTableRuntimeFactory` to implement the `TableRuntimeFactory` process APIs:
  - Aggregate installed `ProcessFactory` instances by `TableFormat` / `Action` and expose derived `ActionCoordinator` plugins via `supportedCoordinators()`
  - Merge `DefaultTableRuntime.REQUIRED_STATES` with additional states required by all process factories for the same format when building `TableRuntimeCreator`
  - Keep using `DefaultTableRuntime` without introducing extra runtime types
- Introduce `DefaultActionCoordinator` to bridge `ProcessFactory` trigger/recover semantics to the existing scheduler:
  - Build trigger strategies from `ProcessFactory#triggerStrategy`
  - Delegate `trigger` and `recoverTableProcess` to the underlying factory
- Add `TableProcessFactoryManager` as an `AbstractPluginManager<ProcessFactory>` using the `process-factories` plugin namespace
- Refactor `AmoroServiceContainer` startup sequence:
  - Initialize `TableProcessFactoryManager` and collect all installed `ProcessFactory` instances
  - Initialize all `TableRuntimeFactory` plugins with the shared list of process factories
  - Collect all derived `ActionCoordinator`s from table runtime factories and inject them into `ProcessService`
- Update `ProcessService` to accept a pre-built list of `ActionCoordinator`s while keeping the original constructors for backward compatibility and tests
- Run `mvn spotless:apply` and `mvn -pl amoro-ams -am -DskipTests compile` to ensure style and compilation pass

Co-Authored-By: Aime <aime@bytedance.com>
Change-Id: Iaa867503c8b0bf93c2b7f0b8fe7d752e2ddbac67
@github-actions github-actions bot added the module:ams-server Ams server module label Feb 26, 2026
@baiyangtx baiyangtx marked this pull request as ready for review February 26, 2026 13:32
@baiyangtx baiyangtx changed the title [Feature]: Load process factories via DefaultTableRuntimeFactory [Improvement]: Load process factories via DefaultTableRuntimeFactory Feb 26, 2026
zhangyongxiang.alpha and others added 2 commits March 4, 2026 13:24
…in and use default runtime

## Summary

Decouple `TableRuntimeFactory` from the generic `ActivePlugin` mechanism and make `AmoroServiceContainer` explicitly use `DefaultTableRuntimeFactory` as the default implementation.

## Details

- Change `TableRuntimeFactory` in `amoro-common` so it no longer extends `ActivePlugin`, keeping only process-related APIs:
  - `List<ActionCoordinator> supportedCoordinators()`
  - `void initialize(List<ProcessFactory> factories)`
  - `Optional<TableRuntimeCreator> accept(ServerTableIdentifier, Map<String, String>)`
- Refactor `TableRuntimeFactoryManager` in AMS:
  - Remove inheritance from `AbstractPluginManager<TableRuntimeFactory>` to avoid the `ActivePlugin` constraint
  - Implement a simple manager that wraps a provided `List<TableRuntimeFactory>`
  - Provide a default no-arg constructor that installs a single `DefaultTableRuntimeFactory`
  - Keep `initialize()` as a no-op and `installedPlugins()` as the accessor to preserve existing wiring in `DefaultTableService`
- Update `DefaultTableRuntimeFactory`:
  - Remove `@Override` annotations from `open/close/name` since they no longer implement `ActivePlugin` methods
  - Keep the methods as no-op helpers with the same behavior
- Update `AmoroServiceContainer.startOptimizingService` to use `DefaultTableRuntimeFactory` directly:
  - Construct a `DefaultTableRuntimeFactory` instance explicitly
  - Wrap it into `TableRuntimeFactoryManager` via `Collections.singletonList(tableRuntimeFactory)`
  - Use the resulting singleton list as the only table runtime factory when initializing process factories and collecting `ActionCoordinator`s
- Leave `DefaultTableService` logic unchanged, it still uses `TableRuntimeFactoryManager.installedPlugins()` but now operates over the explicit default factory list
- Ensure `ProcessService` changes from previous step are included in this commit so the module compiles cleanly

## Verification

- Ran `./mvnw -pl amoro-ams -am -DskipTests compile` from repo root
  - Build succeeded for the full AMS reactor
  - `spotless` and `checkstyle` passed with only existing warnings unrelated to this change

Co-Authored-By: Aime <aime@bytedance.com>
Change-Id: Ifa8deef0d2553176300cdef2c0cb073d52ee3303
… default factory

## Summary

- Remove TableRuntimeFactoryManager indirection and wire DefaultTableService directly with a TableRuntimeFactory implementation.
- Simplify DefaultTableRuntimeFactory after decoupling from plugin framework and ActivePlugin lifecycle.
- Inline default table runtime factory wiring into AmoroServiceContainer and tests, and update process/service initialization.

## Details

- DefaultTableService
  - Change constructor to accept a TableRuntimeFactory instead of TableRuntimeFactoryManager.
  - Replace iteration over installed factories with a single factory.accept(...) call when creating TableRuntime instances.

- DefaultTableRuntimeFactory
  - Drop unused ActivePlugin-style methods: open(Map<String, String>), close(), and name().

- AmoroServiceContainer
  - Instantiate a single DefaultTableRuntimeFactory in startOptimizingService and pass it into DefaultTableService.
  - Initialize the defaultRuntimeFactory with ProcessFactory plugins and derive ActionCoordinators from it directly.

- Tests
  - AMSServiceTestBase: construct DefaultTableService with a concrete DefaultTableRuntimeFactory instead of a mocked TableRuntimeFactoryManager.
  - TestDefaultTableRuntimeHandler: hold a DefaultTableRuntimeFactory field and pass it into DefaultTableService for all test setups.

- Cleanup
  - Delete TableRuntimeFactoryManager class and remove all references and related imports across main and test code.
  - Fix spotless formatting violations in the touched files so that `mvn -pl amoro-ams -am -DskipTests compile` passes.

Co-Authored-By: Aime <aime@bytedance.com>
Change-Id: I8acca1841470dfc1bbd87b77e424a34f4d52ae82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant